<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>2.methods实现</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../js/vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      姓：<input type="text" v-model="firstName"> <br>
      名：<input type="text" v-model="lastName"> <br>
      全名：<span>{{getFullName()}}</span> <br>
      全名：<span>{{getFullName()}}</span> <br>
      全名：<span>{{getFullName()}}</span> <br>
      全名：<span>{{getFullName()}}</span> <br>
      全名：<span>{{getFullName()}}</span> <br>
      全名：<span>{{getFullName()}}</span> <br>
      <hr>
      <h2>当前的和是{{sum}}</h2>
      <button @click="add">点我sum+1</button>
    </div>

    <script type="text/javascript">
      new Vue({
        el:'#demo',
        data:{
          firstName:'zhang',
          lastName:'san',
          sum:0
        },
        methods:{
          add(){
            this.sum += 1
          },
          getFullName(){
            console.log('getFullName')
            return this.firstName.slice(0,1).toUpperCase() + this.firstName.slice(1) + '-' + this.lastName
          }
        }
      })
    </script>
  </body>
</html>